package com.javandad.app.client.profile;

import com.google.gwt.user.client.ui.DeckPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextBox;

public class TextEdit extends DeckPanel {
	protected boolean editable;
	public final TextBox edit = new TextBox();
	public final Label read = new Label();
	
	public TextEdit(boolean editable)
	{
		this.add(read);
		this.add(edit);
		setEditable(editable);
	}
	
	public void setText(String text)
	{
		edit.setText(text);
		read.setText(text);
	}
	public String getText()
	{
		return edit.getText();
	}
	
	public boolean getEditable()
	{
		return editable;
	}
	public void setEditable(boolean editable)
	{
		this.editable = editable;
		if(editable == false)
			read.setText(edit.getText());
		this.showWidget((editable ? 1 : 0));
	}
}
